package com.zhuqi.configuration;

import lombok.extern.log4j.Log4j2;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author : ZhuQi
 * @version : 时间:2022/8/9 10:16 版本:
 * Spring 容器关闭钩子函数
 */
@Log4j2
public class ShutDownHook extends Thread{

    private ConfigurableApplicationContext context;

    public ShutDownHook(ConfigurableApplicationContext context) {
        super();
        this.context = context;
    }

    /**
     * boot 关闭
     */
    @Override
    public void run() {
        log.info("Start clean the login info.");
        context.close();
        log.info("Spring Boot shutdown");
    }
}
